import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart';
import 'package:get/get.dart';
import 'package:untitled1/app/login/PhoneCodePage.dart';
import 'package:untitled1/app/res/myColors.dart';
import 'package:untitled1/app/utils/utilRouter.dart';
import 'package:untitled1/app/widgets/TitleBar.dart';

import '../broker/modules/home/AppHomePage.dart';
import '../widgets/toast/MyToast.dart';
import 'LoginPapgeController.dart';

class LoginPage extends StatefulWidget {
  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  final LoginPapgeController controller = Get.put(LoginPapgeController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      appBar: TitleBar(title: "登录", showBack: false),
      backgroundColor: Colors.white,
      body: Container(
        width: double.infinity,
        height: double.infinity,
        child: Column(
          children: [
            Container(width: double.infinity, height: 50),
            Center(child: Text("欢迎来到家科技")),
            Container(
              width: double.infinity,
              height: 50,
              margin: EdgeInsets.fromLTRB(15, 20, 15, 0),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(8), // 圆角半径 8
                border: Border.all(
                  color: Colors.grey, // 边框颜色（灰色）
                  width: 1, // 边框宽度 1
                ),
              ),

              child: TextField(
                keyboardType: TextInputType.text,
                maxLength: 11,
                decoration: InputDecoration(
                  counterText: '',
                  border: InputBorder.none, // 隐藏 TextField 默认边框
                  contentPadding: EdgeInsets.symmetric(horizontal: 12),
                  hintText: '请输入手机号',
                  // 内边距（调整文字位置）
                ),
                onChanged: (value) {
                  controller.name.value = value;
                  controller.phone_number.value=value;
                },
              ),
            ),
            Container(
              width: double.infinity,
              height: 50,
              margin: EdgeInsets.fromLTRB(15, 20, 15, 0),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(8), // 圆角半径 8
                border: Border.all(
                  color: Colors.grey, // 边框颜色（灰色）
                  width: 1, // 边框宽度 1
                ),
              ),

              child: TextField(
                keyboardType: TextInputType.number,
                maxLength: 11,
                decoration: InputDecoration(
                  counterText: '',
                  border: InputBorder.none, // 隐藏 TextField 默认边框
                  contentPadding: EdgeInsets.symmetric(horizontal: 12),
                  hintText: '请输入密码',
                  // 内边距（调整文字位置）
                ),
                onChanged: (value) {
                  controller.pwd.value = value;
                },
              ),
            ),
            Container(
              width: double.infinity,
              height: 30,
              padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
              child: Text(
                "限8-16位，数字、大小写字母、特殊字符（不能有空格和表情）\n中的至少3种组合",
                style: TextStyle(fontSize: 10, color: myColors.red),
              ),
            ),
            Container(
              width: double.infinity,
              height: 50,
              margin: EdgeInsets.fromLTRB(15, 50, 15, 0),
              child: ElevatedButton(
                child: Text('登录', style: TextStyle(color: Colors.white)),
                onPressed: () {
                  // utilRouter.to(JingJiRenHomePage());
                  // utilRouter.to(VerificationCodePage(phone_number: controller.phone_number.value));
                },
                style: ButtonStyle(
                  backgroundColor: MaterialStateProperty.all<Color>(
                    Colors.blue,
                  ),
                ),
              ),
            ),
            Expanded(
              child: Align(
                alignment: Alignment.bottomCenter,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Container(
                      child: Obx(
                        () => Checkbox(
                          value: controller.is_select.value,
                          onChanged: (v) {
                            print(">]v=${v}");
                            controller.is_select.value =
                                !controller.is_select.value; // 切换状态
                          },
                        ),
                      ),
                    ),
                    Container(
                      // height: 50,
                      child: Column(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Row(
                            mainAxisSize: MainAxisSize.min,
                            children: [
                              Text("我已阅读并同意", style: TextStyle(fontSize: 10,color: Colors.red)),
                              Text(
                                "《用户协议》，《隐私政策》",
                                style: TextStyle(
                                  color: Colors.blue,
                                  fontSize: 10,
                                ),
                              ),
                            ],
                          ),
                          Row(
                            mainAxisSize: MainAxisSize.min,
                            children: [
                              Text("及", style: TextStyle(fontSize: 10)),
                              Text(
                                "《第三方SDK类服务商说明》",
                                style: TextStyle(
                                  color: Colors.blue,
                                  fontSize: 10,
                                ),
                              ),
                            ],
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
